<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" session="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <title>用户详情</title>

    <link href="${pageContext.request.contextPath}/static/css/common.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/font-awesome-4.3.0/css/font-awesome.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/css/select2.min.css"
          rel="stylesheet">
    <!-- jqgrid-->
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/custom.ui.jqgrid.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/style.css" rel="stylesheet">

    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.form.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/common.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/i18n/grid.locale-cn.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/minified/jquery.jqGrid.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/layer/layer.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/static/js/global.js"></script>
	<script src="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/js/select2.min.js"></script>
	<script type="text/javascript"
            src="${pageContext.request.contextPath}/static/plugins/My97DatePicker/WdatePicker.js"></script>
    <style type="text/css">
        .main h5 a {
            position: absolute;
            right: 20px;
            font-size: 14px;
            bottom: 0px;
            display: inline-block;
            padding: 5px;
        }

        .table_list tbody tr {
            height: 35px;
            text-align: center;
        }
        .td1{border:solid #CCCCCC; border-width:0px 1px 1px 0px; padding:10px 0px; width: 30%;}
        .td2{border:solid #CCCCCC; border-width:0px 1px 1px 0px; padding:10px 0px; width: 30%;}
        .td3{
        	border:solid #CCCCCC; 
        	border-width:0px 1px 1px 0px; 
        	padding:10px 0px; width: 30%;
        	height: 120px;
        	}
        .td4{border:solid #CCCCCC; border-width:0px 1px 1px 0px; padding:10px 0px; width: 30%;height: 120px;}
        .enjoyA{
        	    display: block;
        	    color: black;
        }
        .enjoyA:hover{color: black;}
    	.table{
    		border: solid #CCCCCC;
    		border-width: 1px 0px 0px 1px;
    		text-align: center;
    	}
    	.divBorderY
    	{
    	    border-color: #F5F5F5 !important;
    		border: 1px solid transparent;
    		border-radius: 9px;
    		margin-bottom: 5px;
    	}
    	.divBorderN
    	{
    		border-color: #F5F5F5 !important;
    		border: 1px solid transparent;
    		border-radius: 9px;
    		margin-bottom: 5px;
    		background-color: #C1C1C1;
    		color: white !important;
    	}
    	.divBorderC
    	{
    	    border-color: #F5F5F5 !important;
    		border: 1px solid transparent;
    		border-radius: 9px;
    		margin-bottom: 5px;
    		background-color: white;
    	}
    	.faY{
    		margin-right: 23px;
		    margin-top: 6px;
   			float: right;
		    font-size: 21px;
    	}
    	.faN{
    		margin-right: 23px;
		    margin-top: 6px;
   			float: right;
		    font-size: 21px;
    	}
    	.hY{
    	}
    	.hN{
    		color: white !important;
    	}
    	.inButton{
    		padding: 5px 22px !important;
    		font-size: 15px !important;
    	}
    </style>
</head>
<body view="menu-item-4142">
<jsp:include page="../../top.jsp"></jsp:include>
<div class="right">
 	<div class="wrapper">
	    <div class="jqGrid_wrapper">
	    	<div  class="jg-grid divBorderC">
	    		<h1 style="float:left">姓名:</h1><h1 style="float:left" id="userName"></h1>
	    		<h1 style="float:left;margin-left: 15px;">昵称:</h1><h1 style="float:left" id="nickName"></h1>
	    		<h1 style="float:left;margin-left: 15px;">信誉分:</h1><h1 style="float:left" id="score"></h1>
	    		<h1 style="float:left;margin-left: 15px;" id="ron">小区排名:</h1><h1 style="float:left" id="rownu"></h1>
	    	</div>
	        <div id="div0" class="jg-grid divBorderY">
	            <i class="fa fa-chevron-circle-right faY" id="i0"></i>
	            <h1  class="hY"  id="h0" onclick="uesrDetail()">住户管理</h1>
	        </div>
	        <form class="form-horizontal m-t" id="userForm" ><table id="userTable" class="table"></table></form>
	        
	        <div id="div1" class="jg-grid divBorderN">
	            <i class="fa fa-chevron-circle-down faN" id="i1"></i>
	            <h1 class="hN" id="h1" onclick="keysDetail()">钥匙管理</h1>
	        </div>
	        <table id="jqGrid1"></table>
	        <div id="jqGrid_paper1"></div>
	        
	        <div id="div2" class="jg-grid divBorderN">
	            <i class="fa fa-chevron-circle-down faN" id="i2"></i>
	            <h1 class="hN" id="h2" onclick="lifeDetail()">生活服务</h1>
	        </div>
	        <table id="jqGrid2"></table>
	        <div id="jqGrid_paper2"></div>
	        
	        <div id="div3" class="jg-grid divBorderN">
	            <i class="fa fa-chevron-circle-down faN" id="i3"></i>
	            <h1  class="hN" id="h3" onclick="neighborDetail()">好邻居</h1>
	        </div>
	        <table id="jqGrid3"></table>
	        <div id="jqGrid_paper3"></div>
	        
	        <div id="div4" class="jg-grid divBorderN">
	            <i class="fa fa-chevron-circle-down faN" id="i4"></i>
	            <h1  class="hN" id="h4" onclick="enjoyDetail()">乐享</h1>
	        </div>
	        <table id="enjoyTable" class="table"></table>
	        
	        <div id="div5" class="jg-grid divBorderN">
	            <i class="fa fa-chevron-circle-down faN" id="i5"></i>
	            <h1  class="hN" id="h5" onclick="userScoreLogDetail()">信誉分</h1>
	        </div>
	        <table id="jqGrid5"></table>
	        <div id="jqGrid_paper5"></div>
	        
	    </div>
    </div>
</div>
<script>
    $(document).ready(
            function () {
                $.jgrid.defaults.styleUI = "Bootstrap";
                $("#jqGrid1").jqGrid({
                    url: "/admin/tkeys_keysDetailQuery.action",
                    mtype: 'POST',
                    datatype: "local",
                    height: 350,
                    autowidth: true,
                    shrinkToFit: true,
                    rowNum: 10,
                    rowList: [10, 20, 30],
                    colNames: ['序号', '门禁名称', '硬件PID', '开门次数', '分享记录', '有效期', '钥匙状态操作'],
                    colModel: [{
                        name: "SID",
                        index: "SID",
                        key: true,
                        hidden: true
                    }, {
                        name: 'LOCK_NAME',
                        index: 'LOCK_NAME',
                    }, {
                        name: 'PID',
                        index: 'PID',
                    }, {
                        name: 'OPENNUM',
                        index: 'OPENNUM',
                        formatter: function (cellvalue, options, rawObject) {
                       	 if(!cellvalue){
                                return "0";
                            }else if(cellvalue == '-1'){
                            	return '';
                            }else{
                                return '<a style="border-bottom:1px solid #337ab7;" href="javascript:;" onclick="javascript:post(\'${pageContext.request.contextPath}/admin/openlog_listView.action\',{userId:\''+rawObject.USERID+'\',pid:\''+rawObject.PID+'\'})">'+cellvalue+'</a>';
                            }
                       }
                    },{
                    	name: 'SHARENUM',
                        index: 'SHARENUM',
                        formatter: function (cellvalue, options, rawObject) {
                        	 if(!cellvalue){
                                 return "0";
                             }else if(cellvalue == '-1'){
                             	return '';
                             }else{
                                 return '<a style="border-bottom:1px solid #337ab7;"  href="#"  onclick="share(\''+rawObject.USERID+'\',\''+rawObject.PID+'\')">'+cellvalue+'</a>';
                             }
                        }
                    }, {
                        name: "VALIDITY1",
                        index: "VALIDITY1",
                        formatter: function (cellvalue, options, rawObject) {
                            if(cellvalue!= ""){
                            	return '<a style="border-bottom:1px solid #337ab7;" onclick="overdueKeys('+rawObject.SID+',\''+cellvalue+'\')" >'+cellvalue+'</a>';
                            }else{ 
                                return '';
                            }
                        }
                    }, {
                        name: "STATUS",
                        index: "STATUS",
                        formatter: function (cellvalue, options, rawObject) {
                            if(cellvalue!= ""){
                            	if(cellvalue=='2'){
                                	return '换锁失效';
                                }
	                        	var tempStrs = rawObject.VALIDITY1.split("-");
	                        	var year = parseInt(tempStrs[0], 10);
	                        	var month = parseInt(tempStrs[1], 10) - 1;
	                        	var day = parseInt(tempStrs[2], 10);
	                        	var now = new Date();
	                        	var date = new Date(year, month, day, 0, 0, 0);
	                        	if (date<now) {
	                        		return '<input type="button" style="padding: 2px 10px" class="btn btn-success" value="已过期 " onmouseover="this.value=\'延长日期\';" onmouseout="this.value=\'已过期\';" onclick="overdueKeys('
	                        		+rawObject.SID+',\''+rawObject.VALIDITY1+'\')"/>';
								}else{
									if(cellvalue == '0'){
		                                 return '<input type="button" style="padding: 2px 10px" class="btn btn-success" onmouseover="this.value=\'停用\';" onmouseout="this.value=\'正常\';" value="正常" onclick="changeKeys('
		                                 + rawObject.SID + ',1)"/>';
		                             }else{
		                            	 return '<input type="button" style="padding: 2px 10px" class="btn btn-success" value="已停用 " onmouseover="this.value=\'恢复正常\';" onmouseout="this.value=\'已停用\';" onclick="changeKeys('
		                                 + rawObject.SID + ',0)"/>';
		                             }
								}
                            }else{
                                return '';
                            }
                       }
                    }],
                    sortname: 'sid',
                    rownumbers: true,
                    jsonReader: {
                        root: 'rows',
                        page: "page",
                        total: 'total',
                        records: "records",
                        repeatitems: false
                    },
                    pager: "#jqGrid_paper1",
                    viewrecords: true,
                    multiselect: false,
                    hidegrid: false,
                    loadComplete: function(){
                		var re_records = Number($("#jqGrid1").getGridParam('records'));
                		var page = Number($("#jqGrid1").getGridParam('page'));
                		var rows=Number($("#jqGrid1").getGridParam('rowNum'));
                		var num = re_records-(page-1)*rows;
                		if(num < rows)
                		{
                			for(var i=num;i<rows;i++){
                				$("#jqGrid1").jqGrid("addRowData",(i+1),
                        				{ 'SID':'', 'LOCK_NAME':'', 'PID':'', 'OPENNUM':'-1', 'SHARENUM':'-1','VALIDITY1':'','STATUS':''}
                				,"");
                			}
                			$(".ui-paging-info").html(re_records-num+1 +" - "+re_records+"　共 "+re_records+" 条");
                		}
                	}
                });
                $("#jqGrid2").jqGrid({
                    url: "",
                    mtype: 'POST',
                    datatype: "local",
                    height: 350,
                    autowidth: true,
                    shrinkToFit: true,
                    rowNum: 10,
                    rowList: [10, 20, 30],
                    colNames: ['序号', '订单编号', '订单名称', '创建时间', '订单金额', '状态', '成交时间'],
                    colModel: [{
                        name: "SID",
                        index: "SID",
                        key: true,
                        hidden: true
                    }, {
                        name: 'LOCK_NAME',
                        index: 'LOCK_NAME',
                    }, {
                        name: 'PID',
                        index: 'PID',
                    }, {
                        name: 'OPENNUM',
                        index: 'OPENNUM',
                    },{
                        name: 'SHARENUM',
                        index: 'SHARENUM',
                    }, {
                        name: "VALIDITY1",
                        index: "VALIDITY1",
                    }, {
                        name: "VALIDITY2",
                        index: "VALIDITY2",
                        
                    }],
                    sortname: 'sid',
                    rownumbers: true,
                    jsonReader: {
                        root: 'rows',
                        page: "page",
                        total: 'total',
                        records: "records",
                        repeatitems: false
                    },
                    pager: "#jqGrid_paper2",
                    viewrecords: true,
                    multiselect: true,
                    hidegrid: false,
                    loadComplete: function(){
                		var re_records = Number($("#jqGrid2").getGridParam('records'));
                		var page = Number($("#jqGrid2").getGridParam('page'));
                		var rows=Number($("#jqGrid2").getGridParam('rowNum'));
                		var num = re_records-(page-1)*rows;
                		if(num < rows)
                		{
                			for(var i=num;i<rows;i++){
                				$("#jqGrid2").jqGrid("addRowData",(i+1),
                        				{ SID:"",LOCK_NAME:"",PID:"",OPENNUM:"",SHARENUM:"",VALIDITY1:""}
                				,"");
                			}
                			$(".ui-paging-info").html(re_records-num+1 +" - "+re_records+"　共 "+re_records+" 条");
                		}
                	}
                });
                $("#jqGrid3").jqGrid({
                    url: "/admin/useralbum_userAlbumList.action",
                    mtype: 'POST',
                    datatype: "local",
                    height: 350,
                    autowidth: true,
                    shrinkToFit: true,
                    rowNum: 10,
                    rowList: [10, 20, 30],
                    colNames: ['序号', '帖子ID', '帖子内容', '发布时间', '评论数', '点赞数', '操作'],
                    colModel: [{
                        name: "SID",
                        index: "SID",
                        key: true,
                        hidden: true
                    }, {
                        name: 'SID',
                        index: 'SID',
                        width: 40,
                    }, {
                        name: 'ACONTENT',
                        index: 'ACONTENT',
                        formatter: function (cellvalue, options, rawObject) {
                        	if(cellvalue == '-1'){
                             	return '';
                            }else if(cellvalue == null && rawObject.P2 == null){
                        		return "无内容";
                        	}else if(cellvalue != null){
                            	return cellvalue;
                        	}else{
                            	var p = rawObject.P2.split(",");
                            	var img = '';
                            	for (var i = 0; i < p.length; i++) {
                            		img+='<img style="width: 35px;" onclick="showpic(\''+rawObject.USERALBUMPIC+p[i]+'\');" src="'+rawObject.USERALBUMPIC+p[i]+'" />'
								}
                        		return img;
                            }
                        }
                    }, {
                        name: 'CTIME1',
                        index: 'CTIME1',
                        width: 80,
                    },{
                        name: 'COMNUM',
                        index: 'COMNUM',
                        width: 40,
                        formatter: function (cellvalue, options, rawObject) {
                        	if(cellvalue == '-1'){
                             	return '';
                            }else if(rawObject.COMNUM == null){
                        		return "0";
                        	}else{
                        		return rawObject.COMNUM;
                        	}
                        }
                    }, {
                        name: "LIKE_TIME",
                        index: "LIKE_TIME",
                        width: 40,                        
                    }, {
                        name: "ORDER_TOP",
                        index: "ORDER_TOP",
                        width: 80,
                        formatter: function (cellvalue, options, rawObject) {
                        	if(cellvalue == '-1'){
                             	return '';
                            }else if(rawObject.ORDER_TOP == '0'){
                        		return  '<input type="button" style="padding: 2px 10px" class="btn btn-success" value="置顶" onclick="albumOrderTop('
                                + rawObject.SID + ',0)"/><input type="button" style="padding: 2px 10px" class="btn btn-success" value="删除" onclick="deleteAlbum('
                                + rawObject.SID + ')"/>';
                        	}else{
                        		return '<input type="button" style="padding: 2px 10px" class="btn btn-success" value="取消置顶" onclick="albumOrderTop('
                                + rawObject.SID + ',1)"/><input type="button" style="padding: 2px 10px" class="btn btn-success" value="删除" onclick="deleteAlbum('
                                + rawObject.SID + ')"/>';
                        	}
                        }
                    }],
                    sortname: 't.sid',
                    sortorder:'desc',
                    rownumbers: true,
                    jsonReader: {
                        root: 'rows',
                        page: "page",
                        total: 'total',
                        records: "records",
                        repeatitems: false
                    },
                    pager: "#jqGrid_paper3",
                    viewrecords: true,
                    multiselect: false,
                    hidegrid: false,
                    loadComplete: function(){
                		var re_records = Number($("#jqGrid3").getGridParam('records'));
                		var page = Number($("#jqGrid3").getGridParam('page'));
                		var rows=Number($("#jqGrid3").getGridParam('rowNum'));
                		var num = re_records-(page-1)*rows;
                		if(num < rows)
                		{
                			for(var i=num;i<rows;i++){
                				$("#jqGrid3").jqGrid("addRowData",(i+1),
                        				{ SID:"",SID:"",ACONTENT:"-1",CTIME1:"",COMNUM:"-1",LIKE_TIME:"",ORDER_TOP:"-1"}
                				,"");
                			}
                			$(".ui-paging-info").html(re_records-num+1 +" - "+re_records+"　共 "+re_records+" 条");
                		}
                	}
                });
               
                $("#jqGrid5").jqGrid({
                    url: "",
                    mtype: 'POST',
                    datatype: "local",
                    height: 350,
                    autowidth: true,
                    shrinkToFit: true,
                    rowNum: 10,
                    rowList: [10, 20, 30],
                    colNames: ['序号', '时间', '内容', '信誉分'],
                    colModel: [{
                        name: "SID",
                        index: "SID",
                        key: true,
                        hidden: true
                    }, {
                        name: 'CTIME',
                        index: 'CTIME',
                    }, {
                        name: 'MNAME',
                        index: 'MNAME',
                    }, {
                        name: 'INCSCORE',
                        index: 'INCSCORE',
                    }],
                    sortname: 'sid',
                    rownumbers: true,
                    jsonReader: {
                        root: 'rows',
                        page: "page",
                        total: 'total',
                        records: "records",
                        repeatitems: false
                    },
                    pager: "#jqGrid_paper5",
                    viewrecords: true,
                    multiselect: false,
                    hidegrid: false,
                    loadComplete: function(){
                		var re_records = Number($("#jqGrid5").getGridParam('records'));
                		var page = Number($("#jqGrid5").getGridParam('page'));
                		var rows=Number($("#jqGrid5").getGridParam('rowNum'));
                		var num = re_records-(page-1)*rows;
                		if(num < rows)
                		{
                			for(var i=num;i<rows;i++){
                				$("#jqGrid5").jqGrid("addRowData",(i+1),
                        				{ SID:"",CTIME:"",MNAME:"",INCSCORE:""}
                				,"");
                			}
                			$(".ui-paging-info").html(re_records-num+1 +" - "+re_records+"　共 "+re_records+" 条");
                		}
                	}
                });
// 				var mydata1=[
// 							{SID:"",LOCK_NAME:"",PID:"",OPENNUM:"10",SHARENUM:"5",VALIDITY1:"2016-10-10",},
// 							{SID:"",LOCK_NAME:"",PID:"",OPENNUM:"10",SHARENUM:"5",VALIDITY1:"2015-10-10",},
// 							{SID:"",LOCK_NAME:"",PID:"",OPENNUM:"10",SHARENUM:"5",VALIDITY1:"2015-10-10",}
// 						];
				for(var i=0; i<10; i++)  //循环给每行添加数据
				{
					$("#jqGrid2").jqGrid('addRowData',i+1,{SID:"",LOCK_NAME:"",PID:"",OPENNUM:"",SHARENUM:"",VALIDITY1:"",VALIDITY2:""});
				}
				uesrDetail();
            });

    <!--刷新jqGrid表格数据-->
    function refreshGrid1() {
        $("#jqGrid1").trigger("reloadGrid");
    }
    function refreshGrid3() {
        $("#jqGrid3").trigger("reloadGrid");
    }
    function  uesrDetail(){
    	userDetailQuery();
    	$("#gbox_jqGrid1").attr("style","display: none;");
    	$("#gbox_jqGrid2").attr("style","display: none;");
    	$("#gbox_jqGrid3").attr("style","display: none;");
    	$("#enjoyTable").attr("style","display: none;");
    	$("#gbox_jqGrid5").attr("style","display: none;");
    	$("#userTable").removeAttr("style");

    	$(".divBorderY").attr("class","jg-grid divBorderN");
    	$("#div0").attr("class","jg-grid divBorderY");
    	$(".faY").attr("class","fa fa-chevron-circle-down faN");
    	$("#i0").attr("class","fa fa-chevron-circle-right faY");
    	$(".hY").attr("class","hN");
    	$("#h0").attr("class","hY");

    }
    function  keysDetail(){
    	$("#jqGrid1").jqGrid('setGridParam',{datatype:'json'});
    	keysDetailQuery();
    	$("#gbox_jqGrid1").removeAttr("style");
    	$("#userTable").attr("style","display: none;");
    	$("#gbox_jqGrid2").attr("style","display: none;");
    	$("#gbox_jqGrid3").attr("style","display: none;");
    	$("#enjoyTable").attr("style","display: none;");
    	$("#gbox_jqGrid5").attr("style","display: none;");
    	
    	$(".divBorderY").attr("class","jg-grid divBorderN");
    	$("#div1").attr("class","jg-grid divBorderY");
    	$(".faY").attr("class","fa fa-chevron-circle-down faN");
    	$("#i1").attr("class","fa fa-chevron-circle-right faY");
    	$(".hY").attr("class","hN");
    	$("#h1").attr("class","hY");
    }
    function lifeDetail(){
    	$("#gbox_jqGrid2").removeAttr("style");
    	$("#userTable").attr("style","display: none;");
    	$("#gbox_jqGrid1").attr("style","display: none;");
    	$("#gbox_jqGrid3").attr("style","display: none;");
    	$("#enjoyTable").attr("style","display: none;");
    	$("#gbox_jqGrid5").attr("style","display: none;");
    	
    	$(".divBorderY").attr("class","jg-grid divBorderN");
    	$("#div2").attr("class","jg-grid divBorderY");
    	$(".faY").attr("class","fa fa-chevron-circle-down faN");
    	$("#i2").attr("class","fa fa-chevron-circle-right faY");
    	$(".hY").attr("class","hN");
    	$("#h2").attr("class","hY");
    }
    function neighborDetail(){
    	$("#jqGrid3").jqGrid('setGridParam',{datatype:'json'});
    	neighborDetailQuery();
    	$("#gbox_jqGrid3").removeAttr("style");
    	$("#userTable").attr("style","display: none;");
    	$("#gbox_jqGrid1").attr("style","display: none;");
    	$("#gbox_jqGrid2").attr("style","display: none;");
    	$("#enjoyTable").attr("style","display: none;");
    	$("#gbox_jqGrid5").attr("style","display: none;");
    	
    	$(".divBorderY").attr("class","jg-grid divBorderN");
    	$("#div3").attr("class","jg-grid divBorderY");
    	$(".faY").attr("class","fa fa-chevron-circle-down faN");
    	$("#i3").attr("class","fa fa-chevron-circle-right faY");
    	$(".hY").attr("class","hN");
    	$("#h3").attr("class","hY");
    }
    function enjoyDetail(){
    	enjoyQuery();
    	$("#enjoyTable").removeAttr("style");
    	$("#userTable").attr("style","display: none;");
    	$("#gbox_jqGrid1").attr("style","display: none;");
    	$("#gbox_jqGrid2").attr("style","display: none;");
    	$("#gbox_jqGrid3").attr("style","display: none;");
    	$("#gbox_jqGrid5").attr("style","display: none;");

    	$(".divBorderY").attr("class","jg-grid divBorderN");
    	$("#div4").attr("class","jg-grid divBorderY");
    	$(".faY").attr("class","fa fa-chevron-circle-down faN");
    	$("#i4").attr("class","fa fa-chevron-circle-right faY");
    	$(".hY").attr("class","hN");
    	$("#h4").attr("class","hY");
    }
    function userScoreLogDetail(){
    	$("#jqGrid5").jqGrid('setGridParam',{datatype:'json'});
    	userScoreLogQuery();
    	$("#gbox_jqGrid5").removeAttr("style");
    	$("#userTable").attr("style","display: none;");
    	$("#gbox_jqGrid1").attr("style","display: none;");
    	$("#gbox_jqGrid2").attr("style","display: none;");
    	$("#gbox_jqGrid3").attr("style","display: none;");
    	$("#enjoyTable").attr("style","display: none;");

    	$(".divBorderY").attr("class","jg-grid divBorderN");
    	$("#div5").attr("class","jg-grid divBorderY");
    	$(".faY").attr("class","fa fa-chevron-circle-down faN");
    	$("#i5").attr("class","fa fa-chevron-circle-right faY");
    	$(".hY").attr("class","hN");
    	$("#h5").attr("class","hY");
    }
    
    function userDetailQuery(){
		var ifChangeUser =false;
    	$.ajax({
            type: "POST",
            async: false,
            url: '/admin/auth_buttons.action',
            data: "url=" + window.location.pathname,
            success: function (data) {
                data = eval("(" + data + ")");
                for (var i in data) {
                    var action = data[i].mName;
                    switch (action) {
                        case "住户姓名修改":
                        	ifChangeUser = true;
                            break;
                    }
                }
            }
        });
   	 $.post("${pageContext.request.contextPath}/admin/tusers_userDetailQuery.action", {
 	    	'userId':"${userId}"
          }, function (result) {
              result = JSON.parse(result)
              if (result.code == 1) {
                  $("#userName").html(result.name);
                  $("#nickName").html(result.nickName);
                  $("#score").html(result.score);
                  if(result.rownu=='hidden'){
                	  $("#ron").attr("style","display: none;");
                	  $("#rownu").attr("style","display: none;");
                  }else{
	                  $("#rownu").html(result.rownu);
                  }
            	  var table=$("#userTable");
				  table.empty();
				  
				  var tr=$("<tr></tr>");
				  tr.appendTo(table);
				  var td=$("<td class=\"td1\">姓名</td>");
				  td.appendTo(tr);
				  if(ifChangeUser){
				  	var td=$("<td class=\"td2\" id=\"oldName\"><font id='theName'>"+result.name+"</font><input type=\"button\" style=\"padding: 2px 10px;float: right;\" class=\"btn btn-success\" value=\"修改\" onclick=\"changeUser()\" \/></td>");
				  }else{
				  	var td=$("<td class=\"td2\" id=\"oldName\"><font id='theName'>"+result.name+"</font>");
				  }
				  td.appendTo(tr);
				  var td=$("<td class=\"td2\" style='display: none;' id='newDisplayName' ><input type='hidden' name='userSid' id='userSid' value='"+result.sid+"'><input type='text' id='auName' style='width: 70%;display: inline-table;' class='form-control' value='"+result.name+"' />"
						  +"<input type=\"button\" style=\"padding: 2px 10px;float: right;height: 30px;margin-right: 15px;\" class=\"btn btn-success\" value=\"保存\" onclick=\"updateUser()\" \/>"
						  +"<input type=\"button\" style=\"padding: 2px 10px;float: right;height: 30px;margin-right: 15px;\" class=\"btn btn-success\" value=\"取消\" onclick=\"cancelUser()\" \/></td>");
				  td.appendTo(tr);
// 				  var form1=$("<form/>");
// 				  button.appendTo(tr);
				  
				  var tr=$("<tr></tr>");
				  tr.appendTo(table);
				  var td=$("<td class=\"td1\">手机号</td>");
				  td.appendTo(tr);
				  var td=$("<td class=\"td2\">"+result.tel+"</td>");
				  td.appendTo(tr);
				  
				  var tr=$("<tr></tr>");
				  tr.appendTo(table);
				  var td=$("<td class=\"td1\">昵称</td>");
				  td.appendTo(tr);
				  var td=$("<td class=\"td2\">"+result.nickName+"</td>");
				  td.appendTo(tr);

				  var arr = result.comu.split(";");
				  for (var i = 0; i < arr.length; i++) {
					  var tr=$("<tr></tr>");
					  tr.appendTo(table);
						if(i == 0){
				  	  		var td=$("<td class=\"td1\">所属小区</td>");
						}else{
							var td=$("<td class=\"td1\"></td>");
						}
				 		td.appendTo(tr);
				  		var td=$("<td class=\"td2\">"+arr[i]+"</td>");
				  		td.appendTo(tr);
					}
					
				  var tr=$("<tr></tr>");
				  tr.appendTo(table);
				  var td=$("<td class=\"td1\">性别</td>");
				  td.appendTo(tr);
				  var td=$("<td class=\"td2\">"+result.sex+"</td>");
				  td.appendTo(tr);
				  
				  var tr=$("<tr></tr>");
				  tr.appendTo(table);
				  var td=$("<td class=\"td1\">注册时间</td>");
				  td.appendTo(tr);
				  var td=$("<td class=\"td2\">"+result.ctime+"</td>");
				  td.appendTo(tr);

				  
              }else{
              	layer.alert(result.msg);
              }
          });
    }

    function changeUser(){
    	$("#newDisplayName").attr("style","display: false;");
    	$("#oldName").attr("style","display: none;");
    }
    function cancelUser(){
    	$("#oldName").attr("style","display: false;");
    	$("#newDisplayName").attr("style","display: none;");
    }

    function updateUser(){
    	var auName = $("#auName").val();
    	if(!auName){
       	 alert("新用户姓名必填");
       	 return;
        }
        var sid = $("#userSid").val();
    	$.post("${pageContext.request.contextPath}/admin/tusers_update.action", {
	    	'auName': auName,
		    'sid': sid
         }, function (result) {
             result = JSON.parse(result)
             if (result.code == 1) {
            	 $("#oldName").attr("style","display: false;");
            	 $("#theName").html(auName);
             	 $("#newDisplayName").attr("style","display: none;");
             }else{
             	layer.alert(result.msg);
             }
         });
    }
    //钥匙列表
    function keysDetailQuery(){
        $("#jqGrid1").jqGrid('setGridParam', {
            url: "${pageContext.request.contextPath}/admin/tkeys_keysDetailQuery.action",
            postData: {
                'userId': "${userId}"
            }, //发送数据
            page: 1
        }).trigger("reloadGrid"); //重新载入*/
        return false;
   }
    //积分日志
    function userScoreLogQuery(){
        $("#jqGrid5").jqGrid('setGridParam', {
            url: "${pageContext.request.contextPath}/admin/userscorelog_userScoreLogQuery.action",
            postData: {
                'userId': "${userId}"
            }, //发送数据
            page: 1
        }).trigger("reloadGrid"); //重新载入*/
        return false;
   }
    //修改钥匙有效期
    function overdueKeys(sid,validity){
    	layer.open({
            type: 2,
            title: ['修改钥匙有效期', 'font-weight:bold'],
            shadeClose: true, //点击遮罩关闭层
            area: ['387px', '358px'],
            scrollbar: false,
            content: '${pageContext.request.contextPath}/admin/tkeys_changeKeysValidity.action?sid='+sid+'&validity='+validity,
            btn: ['提交', '取消'],
            yes: function (index, layero) {
                var options = {
                    success: function (data) {
                        data = JSON.parse(data);
                        if (data.code == 1) {
                            layer.alert(data.msg, function () {
                                layer.closeAll();
                                refreshGrid1();
                            });
                        } else {
                            layer.alert(data.msg);
                        }
                    }
                };
                $("#layui-layer-iframe" + index).contents().find("#form").ajaxForm(options);
                $("#layui-layer-iframe" + index).contents().find("#form").submit();
            },
            cancel: function (index, layero) {
                layer.close(index);
            }
        });
    }
    //修改钥匙有效期
    function changeKeys(sid,status){
    	 $.post("${pageContext.request.contextPath}/admin/tkeys_changeKeys.action", {
  	    	'sid':sid,
  	    	'status':status
           }, function (result) {
               result = JSON.parse(result)
               if(result.code == 1){
            	   refreshGrid1();
               }
               layer.alert(result.msg);
               
           });
    }
    //钥匙分享
    function share(userId,pid){
    	layer.open({
            type: 2,
            title: ['钥匙分享记录', 'font-weight:bold'],
            shadeClose: true, //点击遮罩关闭层
            area: ['800px', '550px'],
            scrollbar: false,
            content: '${pageContext.request.contextPath}/admin/tkeys_shareKeysView.action?userId='+userId+'&pid='+pid,
            btn: ['确定', '取消'],
            yes: function (index, layero) {
            	layer.close(index);
            },
            cancel: function (index, layero) {
                layer.close(index);
            }
        });
    }
    //好邻居查询
    function neighborDetailQuery(){
        $("#jqGrid3").jqGrid('setGridParam', {
            url: "${pageContext.request.contextPath}/admin/useralbum_userAlbumList.action",
            postData: {
                'userId': "${userId}"
            }, //发送数据
            page: 1
        }).trigger("reloadGrid"); //重新载入*/
        return false;
   }
	//帖子置顶
    function albumOrderTop(sid,status){
   	 $.post("${pageContext.request.contextPath}/admin/useralbum_albumOrderTop.action", {
 	    	'sid':sid,
 	    	'status':status
          }, function (result) {
              result = JSON.parse(result)
              if(result.code == 1){
           	   	refreshGrid3();
              }
              layer.alert(result.msg);
              
          });
   }
   //帖子删除
    function deleteAlbum(sid){
   	 layer.confirm('确认删除所选择的记录', function (index) {
   		$.post("${pageContext.request.contextPath}/admin/useralbum_albumDelete.action", {
 	    	'sid':sid,
          }, function (result) {
              result = JSON.parse(result)
              if(result.code == 1){
           	   refreshGrid3();
              }
              layer.alert(result.msg);
              
          });
         layer.close(index);
     });
   }
    //查看大图
    function showpic(content) {
        var html = '<img style="margin-left: -18px;" width="660px" src="' + content + '" alt="好邻居图片"/>';
        layer.open({
            title: '',
            btn: 0,
            area: ['660px', '95%'],
            content: html
        });
    }
	//乐享查询
    function enjoyQuery(){
    	$.post("${pageContext.request.contextPath}/admin/usersenjoy_usersEnjoyList.action", {
 	    	'userId':"${userId}"
          }, function (result) {
              result = JSON.parse(result)
              if (result.code == 1) {
            	  var table=$("#enjoyTable");
				  table.empty();
				  if(result.rownu !='hidden'){
					  var tr=$("<tr></tr>");
					  tr.appendTo(table);
					  var td=$("<td class=\"td3\"><a style=\"cursor: default;\" class=\"enjoyA\"><font size=\"14px\" color=\"red\">"+result.rownu+"</font></a><a class=\"enjoyA\" style=\"cursor: default;\">住户在本小区乐享的排名</a></td>");
					  td.appendTo(tr);
					  var td1;
					  if(typeof(result.ENJOYORDER)=="undefined"){
						  td1=$("<td class=\"td4\"><input type=\"button\" style=\"padding: 2px 10px;width: 175px;\" class=\"inButton btn btn-success\" value=\"本小区乐享置顶 \" disabled /> &nbsp;&nbsp;&nbsp;&nbsp;* 置顶后，小区的邻居们更容易看到TA哦~</td>");
					  }else if(result.ENJOYORDER ==0){
						  td1=$("<td class=\"td4\"><input type=\"button\" style=\"padding: 2px 10px;width: 175px;\" class=\"inButton btn btn-success\" value=\"本小区乐享置顶 \"  onclick=\"enjoyTop("
	                          +result.COMMUNITYID + ",0)\"/> &nbsp;&nbsp;&nbsp;&nbsp;* 置顶后，小区的邻居们更容易看到TA哦~</td>");
					  }else{
						  td1=$("<td class=\"td4\"><input type=\"button\" style=\"padding: 2px 10px;width: 175px;\" class=\"inButton btn btn-success\" value=\"取消本小区乐享置顶 \"  onclick=\"enjoyTop("
		                      +result.COMMUNITYID + ",1)\"/> &nbsp;&nbsp;&nbsp;&nbsp;* 置顶后，小区的邻居们更容易看到TA哦~</td>");
					  }
					  td1.appendTo(tr);
				  }
				  
				  var tr=$("<tr></tr>");
				  tr.appendTo(table);
				  if(!result.ctime){
					  var td=$("<td class=\"td3\"><a style=\"cursor: default;\" class=\"enjoyA\">用户发布了<font size=\"14px\" color=\"red\">"+result.picNum+"</font>张乐享图片</a><a class=\"enjoyA\" style=\"cursor: default;\">最后发布时间："+result.CTIME+"</a></td>");
				  }else{
					  var td=$("<td class=\"td3\"><a style=\"cursor: default;\" class=\"enjoyA\">用户发布了<font size=\"14px\" color=\"red\">"+result.picNum+"</font>张乐享图片</a><a class=\"enjoyA\" style=\"cursor: default;\">最后发布时间：未知</a></td>");
				  }
				  td.appendTo(tr);
				  if(typeof(result.USERID)!="undefined"){
				  	var td=$("<td class=\"td4\"><input type=\"button\" style=\"padding: 2px 10px;width: 175px;\" class=\"inButton btn btn-success\" value=\"清空用户乐享内容 \" onclick=\"cleanEnjoy('" + result.USERID + "')\"/>"+
						  "<span style=\"font-size:19px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>");
				  }else{
				  	var td=$("<td class=\"td4\"><input type=\"button\" style=\"padding: 2px 10px;width: 175px;\" class=\"inButton btn btn-success\" value=\"清空用户乐享内容 \" disabled /> "+
						  "<span style=\"font-size:19px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>");
				  }
				  td.appendTo(tr);
				
              }else{
              	layer.alert(result.msg);
              }
          });
    }
    //乐享置顶
    function enjoyTop(communityid,status){
      	 $.post("${pageContext.request.contextPath}/admin/usersenjoy_enjoyTop.action", {
    	    	'userid':"${userId}",
    	    	'communityid':communityid,
    	    	'status':status
             }, function (result) {
                 result = JSON.parse(result)
                 if(result.code == 1){
                	 enjoyQuery();
                 }
                 layer.alert(result.msg);
             });
      }
    //清空乐享
    function cleanEnjoy(userid){
    	 $.post("${pageContext.request.contextPath}/admin/usersenjoy_cleanEnjoy.action", {
 	    	'userid':userid
          }, function (result) {
              result = JSON.parse(result)
              layer.alert(result.msg);
          });
    }
    function post(url,params) {
    	var temp = document.createElement("form");
    	temp.action = url;
    	temp.method = "post";
    	temp.style.display = "none";
    	for (var x in params) {
    	var opt = document.createElement("textarea");
    	opt.name = x;
    	opt.value = params[x];
    	temp.appendChild(opt);
    	}
    	document.body.appendChild(temp);
    	temp.submit();
    	return temp;
    }
</script>
</body>
</html>
